home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 117 / PC Guia 117.iso / Software / Utils / Software6 / Product17 / mouse_gestures-1.0-fx+mz+tb.xpi / install.js next >
Text File  |  2004-10-07  |  7KB  |  202 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3.  *
  4.  * The contents of this file are subject to the Mozilla Public License Version
  5.  * 1.1 (the "License"); you may not use this file except in compliance with
  6.  * the License. You may obtain a copy of the License at
  7.  * http://www.mozilla.org/MPL/
  8.  *
  9.  * Software distributed under the License is distributed on an "AS IS" basis,
  10.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11.  * for the specific language governing rights and limitations under the
  12.  * License.
  13.  *
  14.  * The Original Code is the Linky
  15.  *
  16.  * The Initial Developer of the Original Code is Henrik Gemal.
  17.  * Portions created by the Initial Developer are Copyright (C) 2002-2003
  18.  * the Initial Developer. All Rights Reserved.
  19.  *
  20.  * Contributor(s):
  21.  *   Henrik Gemal <linky@gemal.dk> http://gemal.dk
  22.  *   Jens Bannmann <jens.b@web.de>
  23.  *   Jochen <autohide@krickelkrackel.de>
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  27.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38.  
  39. // product related settings
  40. // you can change these
  41. const myProductName = "Mouse Gestures";
  42. const myProductRegKey = "/mozdev/mozgest";
  43.  
  44. // ---- stuff for packaging script --------------------------
  45. // the packaging script (linux) is here: http://goto_scriptxy
  46. // never change the following line!
  47. const myProductRegVersion = "1.0";
  48. // ----------------------------------------------------------
  49.  
  50. const myJarFileName = "mozgest.jar";
  51. const myJarCheckDupe = 1; // check if myJarFileName exist both in personal chrome folder and global chrome folder
  52.  
  53. // global settings
  54. // dont change these
  55. const sysChromeGlobal = getFolder("Chrome");
  56. const sysChromeGlobalJar = getFolder("Chrome", myJarFileName);
  57. const sysChromeUser = getFolder("Current User","chrome");
  58. const sysChromeUserJar = getFolder("Current User", "chrome/" + myJarFileName);
  59.  
  60. function getMessage(key) {
  61.   var msg = new String(Texts[key]);
  62.   msg = new String(msg.replace(/%PRODUCT%/g, Texts.product));
  63.   msg = new String(msg.replace(/%VERSION%/g, myProductRegVersion));
  64.   return msg;
  65. }
  66.  
  67. var err;
  68. var err_tmp;
  69. // init the installation
  70. err_tmp = initInstall(myProductName, myProductRegKey, myProductRegVersion);
  71. if (err_tmp) {
  72.   err = err_tmp;
  73. }
  74.  
  75. var doInstall = true;
  76. var installToProfile;
  77. var Texts = loadResources("install/install.properties");
  78. var msg;
  79.  
  80. if (err) {
  81.   logComment("Problem with initInstall(). Error code: " + err);
  82. } else if (myJarCheckDupe && File.exists(sysChromeGlobalJar) && File.exists(sysChromeUserJar)) {
  83.   var msg = getMessage("doubleinstall");
  84.   msg = new String(msg.replace(/%PROFILE%/, sysChromeUserJar));
  85.   msg = new String(msg.replace(/%GLOBAL%/, sysChromeGlobalJar));
  86.   alert(msg);
  87.   doInstall = false;
  88. } else {
  89.   // Can we install in the personal profile folder?
  90.   if (buildID && buildID >= 2003030700) {
  91.     if (File.exists(sysChromeGlobalJar) || File.exists(sysChromeUserJar)) {
  92.       installToProfile = File.exists(sysChromeUserJar);
  93.       msg = getMessage("existinglocation", false, false);
  94.       msg = msg.replace(/%LOCATION%/, (installToProfile ? Texts.profilechrome
  95.                                                         : Texts.globalchrome));
  96.       if (confirm(msg) == 0) { // 0 = Cancel, 1 = OK
  97.         doInstall = false;
  98.       }
  99.     } else {
  100.       msg = getMessage("chooselocation");
  101.       installToProfile = (confirm(msg) == 0); // 0 = Cancel, 1 = OK
  102.     }
  103.   } else {
  104.     installToProfile = false;
  105.   }
  106. }
  107.  
  108. // did the user cancel, or did an error occur?
  109. if (!doInstall || err) {
  110.   cancelInstall();
  111. } else {
  112.   logComment(myProductName + " version " + myProductRegVersion + " being installed on " + buildID);
  113.   logComment("Installing " + (installToProfile ? "to profile" : "globally"));
  114.  
  115.   // add the jar file
  116.   if (!err) {
  117.     err_tmp = addFile(myProductName, "chrome/" + myJarFileName,
  118.                       (installToProfile ? sysChromeUser : sysChromeGlobal),
  119.                       "");
  120.     if (err_tmp) {
  121.       logComment("Problem adding jar file. Error code: " + err_tmp);
  122.       err = err_tmp;
  123.     } else {
  124.       logComment("ok adding jar file.");
  125.     }
  126.   }
  127.  
  128.   // register the content
  129.   if (!err) {
  130.     if (installToProfile) {
  131.       err_tmp = registerChrome(CONTENT | PROFILE_CHROME, sysChromeUserJar, "content/");
  132.     } else {
  133.       err_tmp = registerChrome(CONTENT | DELAYED_CHROME, sysChromeGlobalJar, "content/");
  134.     }
  135.     if (err_tmp) {
  136.       logComment("Problem registering the content chrome. Error code: " + err_tmp);
  137.       err = err_tmp;
  138.     } else {
  139.       logComment("ok registering the content chrome.");
  140.     }
  141.   }
  142.  
  143.   // register the locale
  144.   if (!err) {
  145.     if (installToProfile) {
  146.       err_tmp = registerChrome(LOCALE | PROFILE_CHROME, sysChromeUserJar, "locale/en-US/mozgest/");
  147.     } else {
  148.       err_tmp = registerChrome(LOCALE | DELAYED_CHROME, sysChromeGlobalJar, "locale/en-US/mozgest/");
  149.     }
  150.     if (err_tmp) {
  151.       logComment("Problem registering the locale chrome. Error code: " + err_tmp);
  152.       err = err_tmp;
  153.     } else {
  154.       logComment("ok registering the locale chrome.");
  155.     }
  156.   }
  157.  
  158.   // register the skin
  159.   if (!err) {
  160.     if (installToProfile) {
  161.       err_tmp = registerChrome(SKIN | PROFILE_CHROME, sysChromeUserJar, "skin/classic/mozgest/");
  162.     } else {
  163.       err_tmp = registerChrome(SKIN | DELAYED_CHROME, sysChromeGlobalJar, "skin/classic/mozgest/");
  164.     }
  165.     if (err_tmp) {
  166.       logComment("Problem registering the skin chrome. Error code: " + err_tmp);
  167.       err = err_tmp;
  168.     } else {
  169.       logComment("ok registering the skin chrome.");
  170.     }
  171.   }
  172.   // do the install
  173.   if (!err) {
  174.     err_tmp = performInstall();
  175.     if (err_tmp < 0) {
  176.       logComment("Problem performing install. Error code: " + err_tmp);
  177.       err = err_tmp;
  178.     } else {
  179.       alert(getMessage("success"));
  180.     }
  181.   }
  182.  
  183.   // did it work?
  184.   if (err) {
  185.     if (err == -202) {
  186.       if (!File.exists(sysChromeGlobalJar)) {
  187.         logComment("Problem installing. Error code: " + err +" Ask user for profile install");
  188.            alert(getMessage("suggestprofileinstall"));
  189.       } else {
  190.         logComment("Problem installing. Error code: " + err +" Tell user the truth");
  191.            alert(getMessage("noglobalinstall"));
  192.         }
  193.     } else {
  194.       logComment("Problem installing. Error code: " + err + ". Error codes can been seen at: " + Texts.errorlist);
  195.       var msg = getMessage("failure");
  196.       msg = msg.replace(/%LINK%/, Texts.errorlist);
  197.       alert(msg);
  198.     }
  199.     cancelInstall(err);
  200.   }
  201. }
  202.